/*
 * @Date         : 2022-06-07 18:48:56
 * @LastEditors  : zu1662
 * @LastEditTime : 2022-11-21 15:27:06
 * @Description  : 系统配置项
 * 
 * Copyright © 2022 by zu1662, All Rights Reserved. 
 */
import { registerAs } from "@nestjs/config";

export default registerAs(
  "app",
  (): Record<string, any> => ({
    name: process.env.APP_NAME || "nest-core-frame",
    env: process.env.APP_ENV || "development",
    mode: process.env.APP_MODE || "simple",
    language: process.env.APP_LANGUAGE || "en",
    timezone: process.env.APP_TZ || "Asia/Shanghai",
    swagger: process.env.APP_SWAGGER || false,

    http: {
      host: process.env.APP_HOST || "localhost",
      port: parseInt(process.env.APP_PORT) || 3000,
    },
    admin: {
      username: process.env.APP_ADMIN_USER || 'admin',
      password: process.env.APP_ADMIN_PASSWORD || 'admin',
    },
    cache: {
      mode: process.env.APP_CACHE_MODE || 'memory',
      ttl: process.env.APP_CHCHE_TTL || 60 * 10, // 默认过期时间，单位：秒
    },
    versioning: process.env.APP_VERSIONING === "true" || false,
    debug: process.env.APP_DEBUG === "true" || false,
    uploadPath: process.env.APP_UPLOADPATH || 'file',
    debugger: {
      http: {
        maxFiles: 5,
        maxSize: "2M",
      },
      system: {
        active: false,
        maxFiles: "7d",
        maxSize: "2m",
      },
    },

    httpOn: process.env.APP_HTTP_ON === "true" ? true : false,
    taskOn: process.env.APP_TASK_ON === "true" || false,
  })
);
